package StudyCode.summary.mycollection;

import java.lang.reflect.Array;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class NewMultiDimensionalArray {
	public static void main(String[] argv) {
		Class elementType = String.class;
		Integer dimensions = 2;
		System.out.println(newMultiArray(elementType, dimensions));
	}

	public static Object newMultiArray(Class<?> elementType,
	                                   Integer... dimensions) {
		int[] dims = new int[dimensions.length];
		int i = 0;
		for (Integer dimension : dimensions) {
			dims[i] = dimension;
			i++;
		}

		return Array.newInstance(elementType, dims);
	}
}
